**# Bookmark #0: main outcomes 
*** Load dataset and prepare variables
**# Bookmark #Define program 
	cd "$code\programs"
	cap prog drop itt_het
	run "prog_itt_hetero.do"
	

use "$data\4_individual_ano_reg_3.dta", clear


merge m:1 id wave using "$data\2_firm_regressions_individual_paper.dta", keepusing(empcat)  
keep if _merge == 3
drop _merge


label var assignment "Assignment"

ren abj Abidjan
replace Abidjan = 2 if Abidjan == 0 
label define Abidjan 2 "Outside Abidjan" 1 "In Abidjan"
label val Abidjan Abidjan

ren a30 Above_30
replace Above_30 = 2 if Above_30 == 0 
label define Above_30 2 "Younger than 30" 1 "30 or older"
label val Above_30 Above_30
 
ren man Male
replace Male = 2 if Male == 0 
label define Male 2 "Female" 1 "Male"
label val Male Male

ren uni  Tertiary_Educ 
replace Tertiary_Educ = 2 if Tertiary_Educ == 0 
label define Tertiary_Educ 2 "Less than Tertiary" 1 "Tertiary"
label val Tertiary_Educ Tertiary_Educ

ren rel Rel_Employer
replace Rel_Employer = 2 if Rel_Employer == 0 
label define Rel_Employer 2 "No relationship" 1 "Friends or Family"
label val Rel_Employer Rel_Employer

ren old Old_Employee
replace Old_Employee = 2 if Old_Employee == 0 
label define Old_Employee 2 "New Employee" 1 "Old Employee"
label val Old_Employee Old_Employee

ren exp Experience 
replace Experience = 2 if Experience == 0 
label define Experience 2 "Up to 5 years" 1 "6+ years"
label val Experience Experience

ren sup Supervisor
replace Supervisor = 2 if Supervisor == 0 
label define Supervisor 2 "No Supervisor" 1 "Supervisor"
label val Supervisor Supervisor

ren empcat Number_Staff
label define Number_Staff 1 "1-3 employees" 2 "4-6 employees" 3 "6+ employees"
label val Number_Staff Number_Staff

*** Specify strata and controls
global se_Number_Staff ", vce(cl id) a(strata_empcat_alt)"
global se_Abidjan ", vce(cl id) a(strata_abidjan_alt)"
global se_Male ", vce(cl id) a(strata_all_coll)"
global se_Tertiary_Educ ", vce(cl id) a(strata_all_coll)"
global se_Experience ", vce(cl id) a(strata_all_coll)"
global se_Above_30 ", vce(cl id) a(strata_all_coll)"
global se_Old_Employee ", vce(cl id) a(strata_all_coll)"
global se_Supervisor ", vce(cl id) a(strata_all_coll)"
global se_Rel_Employer ", vce(cl id) a(strata_all_coll)"

rename assignment Treat

****
* Main heterogeneity table
****

*** Define main parameters
global tbl Table_5_hetero
global outcome aminwage wrcon sosec empquality_ind lwage 

*** Define heterogeneity categories
global het Tertiary_Educ Above_30 Supervisor Rel_Employer 

*** Education labels
global lbl_Tertiary_Educ "A: Employee Education"
global lbl_Tertiary_Educ_1 "Tertiary"
global lbl_Tertiary_Educ_2 "Less than Tertiary"

*** Age labels
global lbl_Above_30 "B: Age"
global lbl_Above_30_1 "30 or older"
global lbl_Above_30_2 "Younger than 30"

*** Supervisor Status labels
global lbl_Supervisor "C: Supervisory Role"
global lbl_Supervisor_1 "Supervisor"
global lbl_Supervisor_2 "No Supervisor"

*** Relationship labels
global lbl_Rel_Employer "D: Relationship with Employer"
global lbl_Rel_Employer_1 "Friends or Family"
global lbl_Rel_Employer_2 "No relationship"


*** Other definitions
global significance " * 0.10 ** 0.05 *** 0.01"
global substitute " "1.Treat             &               &               &               &               \\" " " "

global outputpath "$results\01_tables"
global p=5  // Number of panels per page

**# Bookmark #Define program 
	cd "$code\programs"
	cap prog drop itt_het
	run "prog_itt_hetero.do"
	
	
*** Run the heterogeneity analysis
itt_het

****
* Firm Size Heterogeneity Table
****

global tbl Table_6_hetero

*** Add these to your global het list 
global het Number_Staff

*** Add labels for the new heterogeneity dimensions

*** Firm Size labels
global lbl_Number_Staff "A: Number of Staff"
global lbl_Number_Staff_1 "1-3 employees"
global lbl_Number_Staff_2 "4-6 employees"
global lbl_Number_Staff_3 "6+ employees"

*** Run the heterogeneity analysis
itt_het

****
* Additional Heterogeneity Table
****

global tbl Table_S2_hetero

*** Add these to your global het list 
global het Male Experience Old_Employee Abidjan

*** Add labels for the new heterogeneity dimensions


*** Gender labels
global lbl_Male "A: Gender"
global lbl_Male_1 "Male"
global lbl_Male_2 "Female"


*** Experience labels
global lbl_Experience "B: Experience"
global lbl_Experience_1 "6+ years"
global lbl_Experience_2 "Up to 5 years"

*** Employment Status labels
global lbl_Old_Employee "C: Employment Status"
global lbl_Old_Employee_1 "Old Employee"
global lbl_Old_Employee_2 "New Employee"

*** Location labels
global lbl_Abidjan "D: Location"
global lbl_Abidjan_1 "In Abidjan"
global lbl_Abidjan_2 "Outside Abidjan"



*** Run the heterogeneity analysis
itt_het

